﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI;
using NLBS.Resources;
using System.ComponentModel;

namespace NLBS.Control
{
    [Designer(typeof(EmptyDesigner))]
    public abstract class PanelModule:System.Web.UI.Control
    {
        //protected override HtmlTextWriterTag TagKey
        //{
        //    get
        //    {
        //        return HtmlTextWriterTag.Div;
        //    }
        //}

        private string _title;

        public virtual string Title
        {
            get
            {
                return _title;
            }
            set
            {
                _title = value;
            }
        }

        private ITemplate _itemTemplate;
        [PersistenceMode(PersistenceMode.InnerProperty)]
        public virtual ITemplate ItemTemplate
        {
            get { return _itemTemplate; }
            set { _itemTemplate = value; }
        }

        public override bool EnableViewState
        {
            get
            {
                return false;
            }
        }

        public Dictionary<string, string> lang
        {
            get
            {
                return Language.Instance().getLanguage();
            }
        }

        //protected override void AddAttributesToRender(HtmlTextWriter writer)
        //{
        //    //writer.AddAttribute(HtmlTextWriterAttribute.Class, "panel");
        //    base.AddAttributesToRender(writer);
        //}

        protected override void CreateChildControls()
        {
            //Controls.Add(new LiteralControl(string.Format("<h5>{0}</h5>",Title)));
            
            Controls.Add(new LiteralControl("<div class=\"panel-content\">"));
            _itemTemplate.InstantiateIn(this);
            Controls.Add(new LiteralControl("</div>"));
            base.CreateChildControls();
        }
    }
}
